package cn.iocoder.yudao.module.call.service.cmsipgateway;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import java.util.*;
import cn.iocoder.yudao.module.call.controller.admin.cmsipgateway.vo.*;
import cn.iocoder.yudao.module.call.dal.dataobject.cmsipgateway.CmSipGatewayDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.call.dal.mysql.cmsipgateway.CmSipGatewayMapper;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;

/**
 * 网关配置 Service 实现类
 *
 * @author 数创万维
 */
@Service
@Validated
public class CmSipGatewayServiceImpl implements CmSipGatewayService {

    @Resource
    private CmSipGatewayMapper cmSipGatewayMapper;

    @Override
    public Long createCmSipGateway(CmSipGatewaySaveReqVO createReqVO) {
        // 插入
        CmSipGatewayDO cmSipGateway = BeanUtils.toBean(createReqVO, CmSipGatewayDO.class);
        cmSipGatewayMapper.insert(cmSipGateway);
        // 返回
        return cmSipGateway.getId();
    }

    @Override
    public void updateCmSipGateway(CmSipGatewaySaveReqVO updateReqVO) {
        // 更新
        CmSipGatewayDO updateObj = BeanUtils.toBean(updateReqVO, CmSipGatewayDO.class);
        cmSipGatewayMapper.updateById(updateObj);
    }

    @Override
    public void deleteCmSipGateway(Long id) {
        // 删除
        cmSipGatewayMapper.deleteById(id);
    }

    @Override
    public CmSipGatewayDO getCmSipGateway(Long id) {
        return cmSipGatewayMapper.selectById(id);
    }

    @Override
    public PageResult<CmSipGatewayDO> getCmSipGatewayPage(CmSipGatewayPageReqVO pageReqVO) {
        return cmSipGatewayMapper.selectPage(pageReqVO);
    }

    @Override
    public List<CmSipGatewayDO> getSipGatewayListById(Collection<Long> ids) {
        return cmSipGatewayMapper.selectBatchIds(ids);
    }

    @Override
    public List<CmSipGatewayDO> getSipGatewayList() {
        return cmSipGatewayMapper.selectList();
    }
}